/*******************************************************************************
 * Odbaul Mobile Client - ParseException.java 
 * Copyright (c) Vernalis Systems pvt ltd  2009 
 * This file is licensed from, and is a trade secret of:
 * 	Vernalis Systems pvt ltd
 * 	1,Shakthi Nagar
 * 	Mount Poonamallee road Porur
 * 	Chennai -116
 * TERMS OF USE: Refer your Software License Agreement
 *  Elton Kent - initial API and implementation
 ******************************************************************************/
package com.aphrodite.parser;

import java.io.IOException;

/**
 * a possibly chained exception, indicatin a line and column number.
 * 
 */
class ParseException extends IOException {

	private Exception chained;
	private int columnNumber = -1;
	private int lineNumber = -1;

	/**
	 * Builds a new ParseException with the given message text, chained
	 * Exception, lineNumber, columNumber. Set message text or chained exception
	 * to null and lineNumber and columNumber to -1 if not applicable.
	 */

	ParseException(String msg, Exception chained, int lineNumber, int columnNumber) {

		super((msg == null ? "ParseException" : msg) + " @" + lineNumber + ":" + columnNumber);

		this.chained = chained;
		this.lineNumber = lineNumber;
		this.columnNumber = columnNumber;
	}

	/*
	 * Removed since super is not available in MIDP :(
	 * 
	 * prints the own stack trace followed by the stack trace of the original
	 * exception to the given PrintStream
	 * 
	 * public void printStackTrace (PrintStream p) { super.printStackTrace (p);
	 * if (chained != null) chained.printStackTrace (p); }
	 * 
	 * 
	 * / prints the own stack trace followed by the stack trace of the original
	 * exception to the given PrintWriter
	 * 
	 * public void printStackTrace (PrintWriter p) { super.printStackTrace (p);
	 * if (chained != null) chained.printStackTrace (p); }
	 */

	public int getLineNumber() {
		return lineNumber;
	}

	/**
	 * prints the own stack trace followed by the stack trace of the original
	 * exception.
	 */

	public void printStackTrace() {
		super.printStackTrace();
		if (chained != null)
			chained.printStackTrace();
	}

}
